import os
import sqlite3

__author__ = 'gongqf'
print os.getcwd()
if os.path.exists(r'e:\web\flask\topshipping'):
    os.chdir(r'e:\web\flask\topshipping')
elif os.path.exists(r'l:\web\flask\topshipping'):
    os.chdir(r'l:\web\flask\topshipping')
elif os.path.exists(r'g:\web\flask\topshipping'):
    os.chdir(r'g:\web\flask\topshipping')

conn=sqlite3.connect('topshipping.db3')
conn.text_factory=str
surchargecates=open(r'static\surchargecate.txt').readlines()
for surchargecate in surchargecates:
    surchargecate=surchargecate.strip('\n').split('|')
    conn.execute('replace into surchargecate(surchargecatename,surchargecatenameen,surchargecateshort) values(?,?,?)',(surchargecate[2],surchargecate[1],surchargecate[0]))
conn.commit()